package com.windoent.yugioh.ui.fragment.saishi.end;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.baidu.mobstat.StatService;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import com.windoent.yugioh.R;
import com.windoent.yugioh.adapter.brvah.OnGoingDuiZhenListAdapter;
import com.windoent.yugioh.base.BaseFragment;
import com.windoent.yugioh.bean.GeneralBean;
import com.windoent.yugioh.bean.GeneralDuiZhenBean;
import com.windoent.yugioh.bean.OnGoingDuiZhenBean;
import com.windoent.yugioh.bean.eventbus.FragmentActivityMessageEvent;
import com.windoent.yugioh.constants.Constants;
import com.windoent.yugioh.help.mengceng.lifecycle.FragmentLifecycle;
import com.windoent.yugioh.help.mengceng.util.LogUtil;
import com.windoent.yugioh.http.PhoneLive;
import com.windoent.yugioh.ui.activity.saishi.PanFaDetailsActivity;
import com.windoent.yugioh.ui.activity.saishi.SearchAgainstOnGoingActivity;
import com.windoent.yugioh.utils.BaseMethod;
import com.windoent.yugioh.utils.BaseUtils;
import com.windoent.yugioh.utils.SimpleUtils;
import com.windoent.yugioh.utils.TDevice;
import com.windoent.yugioh.utils.ToastUtils;
import com.windoent.yugioh.widget.RoundImageView;
import com.windoent.yugioh.widget.SearchView;
import com.windoent.yugioh.widget.dialog.PanFaUserDetailsDialog;
import com.windoent.yugioh.widget.dialog.SubmitGradeAgainstDialog;
import com.windoent.yugioh.widget.dialog.SucessFailAutoDismissDialog;
import com.windoent.yugioh.widget.dialog.SureNotDialog;
import com.windoent.yugioh.widget.popupwindow.DuiZhenFilterPopUpWindow;
import com.windoent.yugioh.widget.popupwindow.MeInfoAuthPopUpWindow;
import com.youth.banner.util.BannerUtils;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;

/**
 * author : robert
 * date   : 2021/5/20 12:52
 * desc   :duizhen对阵
 */
public class EndedDuiZhenFragment extends BaseFragment {
    private SmartRefreshLayout mSmartLayout;
    private TextView mTvSelectItem;
    private TextView mBtnGetCode;
    private RecyclerView mRecyclerView;


    private LinearLayout mLlCaipan;
    private LinearLayout mLlSearchXuanshou;

    private SearchView mSearchCaipan;
    private LinearLayout mLlSelectCaipan;

    private SearchView mSearchXuanshou;
    private LinearLayout mLlSearchXuanshouLun;
    private TextView mTvSelectLunXuanshou;
    private LinearLayout mLlSearchZijiAllLun;
    private TextView mTvSelectZijiAllXuanshou;
    private TextView mBtnCaipanStartRuishilunGames;//裁判显示开启瑞士轮
    private LinearLayout mLlNodata;
    private RelativeLayout mRlSmart;

    private String limit = Constants.PAGETEN;
    private int mCount = 1;
    private OnGoingDuiZhenListAdapter adapter;
    private String roles;
    private String type = "all";//筛选
    private String round = "";//筛选轮数
    private String statusId = "";//4：瑞士轮 5：淘汰赛
    private List<OnGoingDuiZhenBean.DataBean.FilterBean> filter;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_saishi_ended_duizhen;
    }

    public static EndedDuiZhenFragment newsInstance(String id) {
        //创建 Bundle
        EndedDuiZhenFragment fragment = new EndedDuiZhenFragment();
        Bundle lBundle = new Bundle();
        lBundle.putString("id", id);
        fragment.setArguments(lBundle);
        return fragment;
    }

    @Override
    protected void initEventAndData() {
        initView();
        initData();
        initListener();

    }

    private void initListener() {
        mBtnCaipanStartRuishilunGames.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //主裁判开启瑞士轮
                mainRefereeStartRuiShiLunGame();
            }
        });
        mLlSelectCaipan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //瑞士轮第一轮
                showPopSelectCaiPan(mTvSelectItem);
            }
        });
        mLlSearchXuanshouLun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //瑞士轮第一轮
                showPopSelectXuanShou(mTvSelectLunXuanshou);
            }
        });
        mLlSearchZijiAllLun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //筛选自己.全部比赛
                showPopSelectAll(mTvSelectZijiAllXuanshou);
            }
        });
        mSearchCaipan.setListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, SearchAgainstOnGoingActivity.class);
                intent.putExtra("id", id);
                intent.putExtra("round", round);
                intent.putExtra("statusId", statusId);
                intent.putExtra("ended", true);
                startActivity(intent);
            }
        });
        mSearchXuanshou.setListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, SearchAgainstOnGoingActivity.class);
                intent.putExtra("id", id);
                intent.putExtra("round", round);
                intent.putExtra("statusId", statusId);
                intent.putExtra("ended", true);
                startActivity(intent);
            }
        });
        mBtnGetCode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //开启下一轮
                startNextRound();
            }
        });
    }

    //开启下一轮
    private void startNextRound() {
        showLoadingDialog("");
        PhoneLive.startNextRound(getUserToken(), id, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralDuiZhenBean fromJson = gson.fromJson(response, GeneralDuiZhenBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            GeneralDuiZhenBean.DataBean data = fromJson.getData();
                            if (data != null) {
                                String resultBtnType = data.getResultBtnType();//生成赛果类型:auto 默认，onlyone:只剩一个人
                                boolean isResultBtn = data.isIsResultBtn();//是否显示生成赛果按钮
                                boolean isWeedOutBtn = data.isIsWeedOutBtn();//是否显示淘汰赛按钮
                                if (BaseMethod.notNull(resultBtnType) && resultBtnType.equals("auto") && !isResultBtn && !isWeedOutBtn) {
                                    BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_start_game_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                        @Override
                                        public void onDissmiss() {
                                            round = "";
                                            statusId = "";
                                            initRefreshData(type, round, statusId);
                                            fresh(type, round, statusId);
                                        }
                                    });
                                } else if (isResultBtn) {
                                    showProduceResultDialog();
                                } else if (isWeedOutBtn) {
                                    showEliminateDialog();
                                } else if (BaseMethod.notNull(resultBtnType) && resultBtnType.equals("onlyone")) {
                                    showOnlyOneProduceResultDialog();
                                } else
                                    ToastUtils.showText(getString(R.string.string_response_error));
                            } else
                                BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_start_game_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                    @Override
                                    public void onDissmiss() {
                                        round = "";
                                        statusId = "";
                                        initRefreshData(type, round, statusId);
                                        fresh(type, round, statusId);
                                    }
                                });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_start_game_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //确认开启淘汰赛
    private void showEliminateDialog() {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setNoStr(getString(R.string.dl_cancel));
        dialog.setYesStr(getString(R.string.string_sure));
        dialog.setTvContent(getString(R.string.string_eliminate_warning));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                generateEliminateSaShi();
            }
        });
        dialog.show();
    }

    //当前比赛仅剩一人/请直接生成赛果。
    private void showOnlyOneProduceResultDialog() {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setNoStr(getString(R.string.dl_cancel));
        dialog.setYesStr(getString(R.string.string_produce_result));
        dialog.setTvContent(getString(R.string.string_only_people_produce_result_warning));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                produceSaShiReSult();
            }
        });
        dialog.show();
    }

    //确认生成赛果
    private void showProduceResultDialog() {
        SureNotDialog dialog = new SureNotDialog(mContext);
        dialog.setNoStr(getString(R.string.dl_cancel));
        dialog.setYesStr(getString(R.string.string_sure));
        dialog.setTvContent(getString(R.string.string_produce_result_warning));
        dialog.setYesOnclickListener(new SureNotDialog.onYesOnclickListener() {
            @Override
            public void onYesClick() {
                produceSaShiReSult();
            }
        });
        dialog.show();
    }

    //生成赛果
    private void produceSaShiReSult() {
        showLoadingDialog("");
        PhoneLive.produceSaShiReSult(getUserToken(), id, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_produce_result_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    round = "";
                                    statusId = "";
                                    initRefreshData(type, round, statusId);
                                    fresh(type, round, statusId);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_produce_result_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //生成淘汰赛对阵
    private void generateEliminateSaShi() {
        showLoadingDialog("");
        PhoneLive.generateEliminateSaShi(getUserToken(), id, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_generate_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    round = "";
                                    statusId = "";
                                    initRefreshData(type, round, statusId);
                                    fresh(type, round, statusId);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_generate_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //开启对阵信息(瑞士轮)
    private void mainRefereeStartRuiShiLunGame() {
        showLoadingDialog("");
        PhoneLive.mainRefereeStartRuiShiLunGame(getUserToken(), id, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_start_game_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    mBtnCaipanStartRuishilunGames.setVisibility(View.GONE);
                                    mRlSmart.setVisibility(View.VISIBLE);
                                    //发送eventbus粘性事件
                                    FragmentActivityMessageEvent event = new FragmentActivityMessageEvent();
                                    event.setMessage(0);
                                    event.setCurrentFragment(1);
                                    EventBus.getDefault().postSticky(event);
                                    round = "";
                                    statusId = "";
                                    initRefreshData(type, round, statusId);
                                    fresh(type, round, statusId);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_start_game_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //筛选轮数
    private void showPopSelectCaiPan(TextView textView) {
        if (filter != null) {
            new DuiZhenFilterPopUpWindow(mContext, filter, BannerUtils.dp2px(40), new DuiZhenFilterPopUpWindow.OnInterface() {
                @Override
                public void onSelect(OnGoingDuiZhenBean.DataBean.FilterBean filterBean) {
                    textView.setText(BaseMethod.notNullDefaultValueNull(filterBean.getTitle()));
                    round = filterBean.getRounds() + "";
                    statusId = filterBean.getStatusId() + "";
                    initRefreshData(type, round, statusId);
                    fresh(type, round, statusId);
                }
            }).showAtBottom(mLlSelectCaipan, 0, 0);
        } else ToastUtils.showText(getString(R.string.string_no_data));
    }

    //选手筛选
    private void showPopSelectXuanShou(TextView textView) {
        if (filter != null)
            new DuiZhenFilterPopUpWindow(mContext, filter, (float) (TDevice.getScreenWidth() * 0.58), new DuiZhenFilterPopUpWindow.OnInterface() {
                @Override
                public void onSelect(OnGoingDuiZhenBean.DataBean.FilterBean filterBean) {
                    textView.setText(BaseMethod.notNullDefaultValueNull(filterBean.getTitle()));
                    round = filterBean.getRounds() + "";
                    statusId = filterBean.getStatusId() + "";
                    initRefreshData(type, round, statusId);
                    fresh(type, round, statusId);
                }
            }).showAtBottom(mLlSearchXuanshouLun, 0, 0);
        else ToastUtils.showText(getString(R.string.string_no_data));
    }

    //筛选自己/所有
    private void showPopSelectAll(TextView textView) {
        new MeInfoAuthPopUpWindow(mContext, getFiltDataAll(), BannerUtils.dp2px(44), new MeInfoAuthPopUpWindow.OnInterface() {
            @Override
            public void onSelect(String s) {
                textView.setText(s);
                if (s.equals(getString(R.string.string_all_pk_games_info))) {
                    type = "all";
                } else if (s.equals(getString(R.string.string_self_pk_games_info))) {
                    type = "self";
                }
                initRefreshData(type, round, statusId);
                fresh(type, round, statusId);
            }
        }).showAtBottom(mLlSearchZijiAllLun, 0, 0);
    }


    //筛选数据
    private List<String> getFiltDataAll() {
        List<String> list = new ArrayList<>();
        list.clear();
        list.add(getString(R.string.string_all_pk_games_info));
        list.add(getString(R.string.string_self_pk_games_info));
        return list;
    }

    private void initData() {
        initAdapter();
        showUI(true, "", false);
    }

    private void initAdapter() {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        adapter = new OnGoingDuiZhenListAdapter();
        adapter.setEmptyView(LayoutInflater.from(mContext).inflate(R.layout.recycler_view_empty_duizhen, mRecyclerView, false));
        adapter.setAnimationEnable(false);
        mRecyclerView.setNestedScrollingEnabled(false);
        mRecyclerView.setAdapter(adapter);
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
            }
        });
    }

    //判罚类型列表
    private void getPanFaStyleList(String name, String gameId, String userId, String vid) {
        PhoneLive.getPanFaStyleList(getUserToken(), gameId, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                if (BaseUtils.isJSONValid(response)) {
                    try {
                        if (BaseUtils.codeIs0(mContext, response)) {
                            showUserPanFaDialog(name, gameId, userId, response, vid);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                } else {
                    ToastUtils.showText(getContext().getString(R.string.string_response_error));
                }
            }
        });
    }

    //用户对阵判罚记录
    private void showUserPanFaDialog(String name, String gameId, String userId, String response, String vId) {
        PanFaUserDetailsDialog dialog = new PanFaUserDetailsDialog(mContext);
        dialog.setUserStr(name, gameId, userId, response);
        dialog.setOnclickListener(new PanFaUserDetailsDialog.onClickListener() {
            @Override
            public void onClickSure(String type_id, String remark) {
                panfaPlayers(vId, userId, type_id, remark);
            }

            @Override
            public void clickMore() {
                Intent intent = new Intent(mContext, PanFaDetailsActivity.class);
                intent.putExtra("gameId", gameId);
                intent.putExtra("userId", userId);
                mContext.startActivity(intent);
            }
        });
        dialog.show();
    }

    //判罚操作
    private void panfaPlayers(String vid, String userId, String type_id, String remark) {
        PhoneLive.panfaPlayers(getUserToken(), vid, userId, type_id, remark, statusId, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, mContext.getString(R.string.string_panfa_player_sucess)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {

                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, mContext.getString(R.string.string_panfa_player_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(mContext.getString(R.string.string_response_error));
                }
            }
        });
    }

    //自己的参加的比赛
    private void addHeader(OnGoingDuiZhenListAdapter adapter, OnGoingDuiZhenBean.DataBean.ResBean item) {
        if (isAdded() && getActivity() != null) {
            View headView = getLayoutInflater().inflate(R.layout.head_rv_view_ongoing_xuanshou_games, (ViewGroup) mRecyclerView.getParent(), false);

            TextView submirBtn = headView.findViewById(R.id.btn_get_code);
            ImageView iv_vs = headView.findViewById(R.id.iv_vs);
            LinearLayout ll_left_normal = headView.findViewById(R.id.ll_left_normal);
            LinearLayout ll_left_big = headView.findViewById(R.id.ll_left_big);
            LinearLayout ll_luck_lun_null_right = headView.findViewById(R.id.ll_luck_lun_null_right);
            LinearLayout ll_right_normal = headView.findViewById(R.id.ll_right_normal);
            LinearLayout ll_right_big = headView.findViewById(R.id.ll_right_big);

            TextView tv_game_id_xuanshou = headView.findViewById(R.id.tv_game_id_xuanshou);
            TextView tv_game_number_xuanshou = headView.findViewById(R.id.tv_game_number_xuanshou);
            TextView tv_game_status = headView.findViewById(R.id.tv_game_status);
            //左边
            //正常大小
            RoundImageView iv_avatar_left_normal = headView.findViewById(R.id.iv_avatar_left_xuanshou);
            TextView iv_id_left_normal = headView.findViewById(R.id.iv_id_left_xuanshou);
            TextView iv_name_left_xuanshou = headView.findViewById(R.id.iv_name_left_xuanshou);
            //大
            RoundImageView iv_avatar_left_big = headView.findViewById(R.id.iv_avatar_left_xuanshou_big);
            ImageView iv_avatar_left_huangguan_big = headView.findViewById(R.id.iv_sucess_bg_left_huangguan);
            ImageView iv_avatar_left_scry_big = headView.findViewById(R.id.iv_sucess_bg_left_scry_emo);
            TextView iv_id_left_big = headView.findViewById(R.id.iv_id_left_xuanshou_big);
            TextView iv_name_left_big = headView.findViewById(R.id.iv_name_left_xuanshou_big);

            //右边
            //正常
            RoundImageView iv_avatar_right_normal = headView.findViewById(R.id.iv_avatar_right_xuanshou);
            TextView iv_id_right_normal = headView.findViewById(R.id.iv_id_right_xuanshou);
            TextView iv_name_right_xuanshou = headView.findViewById(R.id.iv_name_right_xuanshou);
            //大
            RoundImageView iv_avatar_right_big = headView.findViewById(R.id.iv_avatar_right_xuanshou_big);
            ImageView iv_avatar_right_huangguan_big = headView.findViewById(R.id.iv_sucess_bg_right_huangguan);
            ImageView iv_avatar_right_scry_big = headView.findViewById(R.id.iv_sucess_bg_right_scry_emo);
            TextView iv_id_right_big = headView.findViewById(R.id.iv_id_right_xuanshou_big);
            TextView iv_name_right_big = headView.findViewById(R.id.iv_name_right_xuanshou_big);

            int status_id = item.getStatus_id();//"1": "进行中", "2": "审核中","3": "成绩有效","4": "成绩无效"
            int a_result = item.getA_result();
            int a_id = item.getA_id();// "0": "还未提交成绩","1": "胜", "2": "平","3": "负","4": "双负"
            int b_result = item.getB_result();
            int b_id = item.getB_id();

            //数据
            tv_game_id_xuanshou.setText(getString(R.string.string_game_id_colon) + BaseMethod.notNullDefaultValueNull(item.getV_id() + ""));
            tv_game_number_xuanshou.setText(BaseMethod.notNullDefaultValueNull(item.getDesk_name()));
            SimpleUtils.loadImageForView(mContext, iv_avatar_left_normal, item.getA_avatar(), R.drawable.img_official_avatar_android);
            SimpleUtils.loadImageForView(mContext, iv_avatar_left_big, item.getA_avatar(), R.drawable.img_official_avatar_android);
            SimpleUtils.loadImageForView(mContext, iv_avatar_right_normal, item.getB_avatar(), R.drawable.img_official_avatar_android);
            SimpleUtils.loadImageForView(mContext, iv_avatar_right_big, item.getB_avatar(), R.drawable.img_official_avatar_android);
            iv_id_left_normal.setText(getString(R.string.string_user_info_id) + BaseMethod.notNullDefaultValueNull(item.getA_id() + ""));
            iv_id_left_big.setText(getString(R.string.string_user_info_id) + BaseMethod.notNullDefaultValueNull(item.getA_id() + ""));
            iv_id_right_normal.setText(getString(R.string.string_user_info_id) + BaseMethod.notNullDefaultValueNull(item.getB_id() + ""));
            iv_id_right_big.setText(getString(R.string.string_user_info_id) + BaseMethod.notNullDefaultValueNull(item.getB_id() + ""));
            iv_name_left_xuanshou.setText(BaseMethod.notNullDefaultValueNull(item.getA_nickname()));
            iv_name_left_big.setText(BaseMethod.notNullDefaultValueNull(item.getA_nickname()));
            iv_name_right_xuanshou.setText(BaseMethod.notNullDefaultValueNull(item.getB_nickname()));
            iv_name_right_big.setText(BaseMethod.notNullDefaultValueNull(item.getB_nickname()));

            submirBtn.setVisibility(status_id == 1 || status_id == 2 ? View.VISIBLE : View.GONE);
            tv_game_status.setText(item.getStatus_view());
            if (status_id == 1) {
                submirBtn.setSelected(false);
                submirBtn.setText(getString(R.string.string_submit_grade));
                iv_vs.setBackgroundResource(R.drawable.drawable_vs_beauty);
                ll_left_normal.setVisibility(View.VISIBLE);
                ll_right_normal.setVisibility(View.VISIBLE);
                ll_left_big.setVisibility(View.GONE);
                ll_right_big.setVisibility(View.GONE);
                ll_luck_lun_null_right.setVisibility(View.GONE);

                //数据
                setHeaderGray(true, true, true, true, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);
            } else if (status_id == 2) {
                submirBtn.setSelected(true);
                submirBtn.setText(getString(R.string.string_reviewing));
                iv_vs.setBackgroundResource(R.drawable.drawable_vs_beauty);
                ll_left_normal.setVisibility(View.VISIBLE);
                ll_right_normal.setVisibility(View.VISIBLE);
                ll_left_big.setVisibility(View.GONE);
                ll_right_big.setVisibility(View.GONE);
                ll_luck_lun_null_right.setVisibility(View.GONE);

                //数据
                setHeaderGray(true, true, true, true, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);
            } else {
                //数据
                if (a_id == getAccountId() && b_id != 0) {
                    //左边是自己
                    if (status_id == 3 && a_result == 1) {//胜利
                        iv_vs.setBackgroundResource(R.drawable.drawable_victory);
                        setHeaderGray(true, true, false, false, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.GONE);
                        ll_left_big.setVisibility(View.VISIBLE);
                        ll_right_normal.setVisibility(View.VISIBLE);
                        ll_right_big.setVisibility(View.GONE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                        iv_avatar_left_huangguan_big.setVisibility(View.VISIBLE);
                        iv_avatar_left_scry_big.setVisibility(View.GONE);
                    } else if (status_id == 3 && (a_result == 2)) {//平
                        iv_vs.setBackgroundResource(R.drawable.drawable_ping);
                        setHeaderGray(true, true, true, true, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.VISIBLE);
                        ll_right_normal.setVisibility(View.VISIBLE);
                        ll_left_big.setVisibility(View.GONE);
                        ll_right_big.setVisibility(View.GONE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                    } else if (status_id == 3 && (a_result == 4)) {//双负
                        iv_vs.setBackgroundResource(R.drawable.drawable_double_defeat);
                        setHeaderGray(false, false, false, false, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.VISIBLE);
                        ll_right_normal.setVisibility(View.VISIBLE);
                        ll_left_big.setVisibility(View.GONE);
                        ll_right_big.setVisibility(View.GONE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                    } else if (status_id == 3 && a_result == 3) {//负
                        iv_vs.setBackgroundResource(R.drawable.drawable_defeat);
                        setHeaderGray(false, false, true, true, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.GONE);
                        ll_left_big.setVisibility(View.VISIBLE);
                        ll_right_normal.setVisibility(View.VISIBLE);
                        ll_right_big.setVisibility(View.GONE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                        iv_avatar_left_scry_big.setVisibility(View.VISIBLE);
                        iv_avatar_left_huangguan_big.setVisibility(View.GONE);
                    }
                } else if (b_id != 0 && b_id == getAccountId()) {
                    if (status_id == 3 && b_result == 1) {//胜利
                        iv_vs.setBackgroundResource(R.drawable.drawable_victory);
                        setHeaderGray(false, false, true, true, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.VISIBLE);
                        ll_left_big.setVisibility(View.GONE);
                        ll_right_normal.setVisibility(View.GONE);
                        ll_right_big.setVisibility(View.VISIBLE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                        iv_avatar_right_huangguan_big.setVisibility(View.VISIBLE);
                        iv_avatar_right_scry_big.setVisibility(View.GONE);
                    } else if (status_id == 3 && (b_result == 2)) {//平
                        iv_vs.setBackgroundResource(R.drawable.drawable_ping);
                        setHeaderGray(true, true, true, true, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.VISIBLE);
                        ll_right_normal.setVisibility(View.VISIBLE);
                        ll_left_big.setVisibility(View.GONE);
                        ll_right_big.setVisibility(View.GONE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                    } else if (status_id == 3 && (b_result == 4)) {//双负
                        iv_vs.setBackgroundResource(R.drawable.drawable_double_defeat);
                        setHeaderGray(false, false, false, false, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.VISIBLE);
                        ll_right_normal.setVisibility(View.VISIBLE);
                        ll_left_big.setVisibility(View.GONE);
                        ll_right_big.setVisibility(View.GONE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                    } else if (status_id == 3 && b_result == 3) {//负
                        iv_vs.setBackgroundResource(R.drawable.drawable_defeat);
                        setHeaderGray(true, true, false, false, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                        ll_left_normal.setVisibility(View.VISIBLE);
                        ll_left_big.setVisibility(View.GONE);
                        ll_right_normal.setVisibility(View.GONE);
                        ll_right_big.setVisibility(View.VISIBLE);
                        ll_luck_lun_null_right.setVisibility(View.GONE);
                        iv_avatar_right_scry_big.setVisibility(View.VISIBLE);
                        iv_avatar_right_huangguan_big.setVisibility(View.GONE);
                    }
                } else if (b_id == 0 && item.isIs_verify()) {
                    //轮空
                    iv_vs.setBackgroundResource(R.drawable.drawable_victory);
                    setHeaderGray(true, true, true, true, iv_avatar_left_normal, iv_id_left_normal, iv_name_left_xuanshou, iv_avatar_left_big, iv_id_left_big, iv_name_left_big, iv_avatar_right_normal, iv_id_right_normal, iv_name_right_xuanshou, iv_avatar_right_big, iv_id_right_big, iv_name_right_big);

                    ll_left_normal.setVisibility(View.GONE);
                    ll_right_normal.setVisibility(View.GONE);
                    ll_left_big.setVisibility(View.VISIBLE);
                    ll_right_big.setVisibility(View.GONE);
                    ll_luck_lun_null_right.setVisibility(View.VISIBLE);
                    iv_avatar_left_huangguan_big.setVisibility(View.VISIBLE);
                    iv_avatar_left_scry_big.setVisibility(View.GONE);
                }
            }
            submirBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (status_id == 1) {
                        if (b_id != 0 && (a_id == getAccountId() || b_id == getAccountId()))
                            showSubmitGradeDialog(item, BaseMethod.notNull(statusId) && statusId.equals("5"));
                        else
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_canot_submit_grade_warning), getString(R.string.string_canot_submit_grade_reason_warning));
                    } else if (status_id == 2) {
                        BaseMethod.showSucessDialog(mContext, getString(R.string.string_reviewing_warning), null);
                    }
                }
            });
            if (adapter != null) {
                adapter.addHeaderView(headView);
                adapter.setHeaderWithEmptyEnable(true);
                if (adapter.hasEmptyView()) {
                    adapter.setUseEmpty(false);
                }
            }
        }
    }

    //头布局亮暗
    private void setHeaderGray(boolean leftNormal, boolean leftBig, boolean rightNormal, boolean rightBig, RoundImageView iv_avatar_left_normal, TextView iv_id_left_normal, TextView iv_name_left_xuanshou, RoundImageView iv_avatar_left_big, TextView iv_id_left_big, TextView iv_name_left_big, RoundImageView iv_avatar_right_normal, TextView iv_id_right_normal, TextView iv_name_right_xuanshou, RoundImageView iv_avatar_right_big, TextView iv_id_right_big, TextView iv_name_right_big) {
        iv_avatar_left_normal.setShape(!leftNormal);
        iv_avatar_left_big.setShape(!leftBig);
        iv_avatar_right_normal.setShape(!rightNormal);
        iv_avatar_right_big.setShape(!rightBig);
        iv_id_left_normal.setSelected(leftNormal);
        iv_id_left_big.setSelected(leftBig);
        iv_id_right_normal.setSelected(rightNormal);
        iv_id_right_big.setSelected(rightBig);
        iv_name_left_xuanshou.setSelected(leftNormal);
        iv_name_left_big.setSelected(leftBig);
        iv_name_right_xuanshou.setSelected(rightNormal);
        iv_name_right_big.setSelected(rightBig);
    }

    //提交成绩
    private void showSubmitGradeDialog(OnGoingDuiZhenBean.DataBean.ResBean item, boolean outGame) {
        SubmitGradeAgainstDialog dialog = new SubmitGradeAgainstDialog(mContext);
        dialog.setDataInfo(item, outGame);
        dialog.setOnclickListener(new SubmitGradeAgainstDialog.onClickListener() {
            @Override
            public void onClick(int selectPosition) {//1胜利，2平，3失败  1：胜 2：平 3：负
                playsSubmitGrade(selectPosition + "", item.getId() + "");
            }
        });
        dialog.show();
    }

    //选手自己提交成绩
    private void playsSubmitGrade(String grade, String vid) {
        showLoadingDialog("");
        PhoneLive.playsSubmitGrade(getUserToken(), vid, grade, statusId, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    GeneralBean fromJson = gson.fromJson(response, GeneralBean.class);
                    if (fromJson != null) {
                        int code = fromJson.getCode();
                        String msg = fromJson.getMsg();
                        if (code == 200) {
                            BaseMethod.showSucessDialog(mContext, BaseMethod.notNullDefaultValue(msg, getString(R.string.string_reward_sure_submit)), new SucessFailAutoDismissDialog.OnInterface() {
                                @Override
                                public void onDissmiss() {
                                    round = "";
                                    statusId = "";
                                    initRefreshData(type, round, statusId);
                                    fresh(type, round, statusId);
                                }
                            });
                        } else {
                            BaseMethod.showFailDialog(mContext, getString(R.string.string_submit_grade_fail), BaseMethod.notNullDefaultValueNull(msg));
                        }
                    }
                } else {
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    private void initView() {
        mSmartLayout = (SmartRefreshLayout) mView.findViewById(R.id.smart_layout);
        mBtnGetCode = (TextView) mView.findViewById(R.id.btn_get_code);
        mRecyclerView = (RecyclerView) mView.findViewById(R.id.recycler_view);

        mBtnCaipanStartRuishilunGames = (TextView) mView.findViewById(R.id.btn_caipan_start_ruishilun_games);

        mLlCaipan = (LinearLayout) mView.findViewById(R.id.ll_caipan);
        mSearchCaipan = (SearchView) mView.findViewById(R.id.search_caipan);
        mLlSelectCaipan = (LinearLayout) mView.findViewById(R.id.ll_select_caipan);
        mTvSelectItem = (TextView) mView.findViewById(R.id.tv_select_item);
        mSearchXuanshou = (SearchView) mView.findViewById(R.id.search_xuanshou);
        mLlSearchXuanshou = (LinearLayout) mView.findViewById(R.id.ll_search_xuanshou);
        mLlSearchXuanshouLun = (LinearLayout) mView.findViewById(R.id.ll_search_xuanshou_lun);
        mTvSelectLunXuanshou = (TextView) mView.findViewById(R.id.tv_select_lun_xuanshou);
        mLlSearchZijiAllLun = (LinearLayout) mView.findViewById(R.id.ll_search_ziji_all_lun);
        mTvSelectZijiAllXuanshou = (TextView) mView.findViewById(R.id.tv_select_ziji_all_xuanshou);
        mLlNodata = (LinearLayout) mView.findViewById(R.id.ll_nodata);
        mRlSmart = (RelativeLayout) mView.findViewById(R.id.rl_smart);
    }

    /**
     * @param role
     * @param isStart 是否开启
     */
    private void showUI(boolean isNull, String role, boolean isStart) {
        mBtnCaipanStartRuishilunGames.setVisibility(View.GONE);
        mSmartLayout.setVisibility(View.VISIBLE);
        if (!isNull) {
            mLlNodata.setVisibility(View.GONE);
            mRlSmart.setVisibility(View.VISIBLE);
        } else {
            mLlNodata.setVisibility(View.VISIBLE);
            mRlSmart.setVisibility(View.GONE);
        }
    }

    //筛选事件显示
    private void showXuanShouSearchUi(boolean isXuanshou, boolean isMainCaipan) {
        mLlCaipan.setVisibility(isXuanshou ? View.GONE : View.VISIBLE);
        mSearchXuanshou.setVisibility(isXuanshou ? View.VISIBLE : View.GONE);
        mLlSearchXuanshou.setVisibility(isXuanshou ? View.VISIBLE : View.GONE);
        mBtnGetCode.setVisibility(isMainCaipan ? View.VISIBLE : View.GONE);
    }

    private void initRefreshData(String type, String round, String statusId) {
        //下拉刷新
        mSmartLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                fresh(type, round, statusId);
            }
        });
    }

    private void loadMore(String type, String round, String statusId) {
        mCount = mCount + 1;
        getOnGingAgainstList(type, round, statusId, mCount + "", limit, false);
    }

    private void fresh(String type, String round, String statusId) {
        mCount = 1;
        getOnGingAgainstList(type, round, statusId, mCount + "", limit, true);
    }

    //对阵详情
    private void getOnGingAgainstList(String type, String round, String statusId, String page, String limit, boolean fresh) {
        showLoadingDialog("");
        PhoneLive.getDuiZHenGameDetails(getUserToken(), id, type, round, statusId, "", new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                hideLoadingDialog();
                ToastUtils.showText(e.getMessage());
                freshFail(fresh);
            }

            @Override
            public void onResponse(String response, int id) {
                hideLoadingDialog();
                if (BaseUtils.isJSONValid(response)) {
                    try {
                        if (BaseUtils.codeIs0(mContext, response)) {
                            details(response, fresh);
                        } else freshFail(fresh);
                    } catch (JSONException e) {
                        freshFail(fresh);
                        e.printStackTrace();
                    }
                } else {
                    freshFail(fresh);
                    ToastUtils.showText(getString(R.string.string_response_error));
                }
            }
        });
    }

    //刷新失败
    private void freshFail(boolean fresh) {
        if (fresh) {
            adapter.setNewInstance(null);
            mSmartLayout.finishRefresh(false);
        } else {
            mSmartLayout.finishLoadMore(false);
        }
    }

    //----------NewbieGuide蒙层-----------

    FragmentLifecycle mFragmentLifecycle;

    public void setFragmentLifecycle(FragmentLifecycle lifecycle) {
        mFragmentLifecycle = lifecycle;
    }

    @Override
    public void onStart() {
        super.onStart();
        LogUtil.d("onStart: ");
        if (mFragmentLifecycle != null) mFragmentLifecycle.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
        if (mFragmentLifecycle != null) mFragmentLifecycle.onStop();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (mFragmentLifecycle != null) mFragmentLifecycle.onDestroyView();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        LogUtil.d("onDestroy: ");
        if (mFragmentLifecycle != null) mFragmentLifecycle.onDestroy();
        OkHttpUtils.getInstance().cancelTag(this);
    }


    @Override
    public void onPause() {
        super.onPause();
        if (getActivity() != null) {
            // 页面埋点
            StatService.onPageEnd(getActivity(), "赛事进行中对阵tab");
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if (getActivity() != null) {
            // 页面埋点
            StatService.onPageStart(getActivity(), "赛事进行中对阵tab");
        }
        getDetailsId();
    }

    private String id = "";

    //获取activity传值id
    private void getDetailsId() {
        Bundle bundle = getArguments();
        if (bundle != null) {
            id = bundle.getString("id");
            round = "";
            statusId = "";
            initRefreshData(type, round, statusId);
            fresh(type, round, statusId);
        }
    }

    //数据
    private void details(String response, boolean fresh) {
        if (BaseUtils.isJSONValid(response)) {
            try {
                if (BaseUtils.codeIs0(mContext, response)) {
                    OnGoingDuiZhenBean json = gson.fromJson(response, OnGoingDuiZhenBean.class);
                    if (json != null) {
                        OnGoingDuiZhenBean.DataBean data = json.getData();
                        if (data != null) {
                            boolean isStart = data.isIsStartMatchAgainst();
                            roles = data.getRoles();
                            boolean isNextRoundBtn = data.isIsNextRoundBtn();
                            List<OnGoingDuiZhenBean.DataBean.ResBean> res = data.getRes();
                            showUI(res == null || res.size() == 0, roles, isStart);
                            boolean player = BaseMethod.notNull(roles) && roles.equals("player");
                            if (res != null && res.size() > 0) {
                                if (adapter != null) {
                                    OnGoingDuiZhenBean.DataBean.ResBean resZero = res.get(0);
                                    boolean is_join = resZero.isIs_join();
                                    if (is_join) {
                                        if (adapter != null && adapter.getHeaderLayoutCount() > 0) {
                                            adapter.removeAllHeaderView();
                                        }
                                        addHeader(adapter, resZero);
                                        res.remove(0);
                                    } else {
                                        if (adapter.hasEmptyView()) {
                                            adapter.setUseEmpty(true);
                                        }
                                        if (adapter != null && adapter.getHeaderLayoutCount() > 0) {
                                            adapter.removeAllHeaderView();
                                        }
                                    }
                                }
                            }
                            assert adapter != null;
                            adapter.setRole(roles);
                            //瑞士轮显示修改
                            adapter.setIsRuiShiLun(false);
                            if (fresh) {
                                mSmartLayout.finishRefresh(true);
                                adapter.setNewInstance(res);
                            } else {
                                mSmartLayout.finishLoadMore(true);
                                adapter.addData(res);
                            }
                            boolean notJoin = BaseMethod.notNull(roles) && roles.equals("notJoin");
                            boolean pReferee = BaseMethod.notNull(roles) && roles.equals("pReferee");
                            boolean referee = BaseMethod.notNull(roles) && roles.equals("referee");
                            boolean customer = BaseMethod.notNull(roles) && roles.equals("customer");
                            boolean customerReferee = BaseMethod.notNull(roles) && roles.equals("customerReferee");
                            boolean pending = BaseMethod.notNull(roles) && roles.equals("pending");
                            showXuanShouSearchUi(false, false);
                            //筛选
                            filter = data.getFilter();
                            OnGoingDuiZhenBean.DataBean.SelectFilterBean selectFilter = data.getSelectFilter();
                            if (selectFilter != null) {
                                round = selectFilter.getRounds() + "";
                                statusId = selectFilter.getStatusId() + "";
                                String title = selectFilter.getTitle();
                                mTvSelectItem.setText(BaseMethod.notNullDefaultValue(title, getString(R.string.string_select_luns_filter_warning)));
                                mTvSelectLunXuanshou.setText(BaseMethod.notNullDefaultValue(title, getString(R.string.string_select_luns_filter_warning)));
                            }
                        } else freshFail(fresh);
                    } else freshFail(fresh);
                } else freshFail(fresh);
            } catch (JSONException e) {
                freshFail(fresh);
                e.printStackTrace();
            }
        } else {
            freshFail(fresh);
            ToastUtils.showText(getString(R.string.string_response_error));
        }
    }
}
